﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;
namespace POSSystem.BLL
{
    public class ProductTags : _ProductTags
    {
        public static ProductTags GetTags(int productID)
        {
            ProductTags tag = new ProductTags();
            tag.Where.ProductID.Value = productID;
            tag.Query.Load();

            return tag;
        }

        public static ProductTags GetTags(string strtag)
        {
            ProductTags tag = new ProductTags();
            tag.Where.Tag.Value = strtag;
            tag.Query.Load();

            return tag;
        }

        public static void DeleteTags(string strtag)
        {
            ProductTags tag = new ProductTags();
            tag.Where.Tag.Value = strtag;
            tag.Query.Load();

            tag.DeleteAll();
            tag.Save();
        }

        public static void AddTag(int productID, string strtag)
        {
            ProductTags tag = new ProductTags();
            tag.Where.ProductID.Value = productID;
            tag.Where.Tag.Value = strtag;
            tag.Query.Load();

            if (tag.RowCount <= 0)
            {
                tag.AddNew();
                tag.ProductID = productID;
                tag.Tag = strtag;
                tag.Save();
            }
        }
    }
}
